<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/6
 * Time: 20:39
 */

namespace app\index\controller;


use think\Db;

class Shere
{
    public function getuserinfo(){
        $member = Db::name('member')->where('id',input('id',7))->find();
        $total = Db::name('member')->where('pid',input('id',7))->count();
        $ticheng =Db::name('ticheng')->where(['userid'=>input('id'), 'ticheng'=>1])->field('sum(money) as money')->select();
        return json(['code'=>1, 'msg'=>'ok','member'=>$member, 'total'=>$total,'ticheng'=>$ticheng[0]['money']??0]);
    }

    public function setTuijian(){
        $param = input();
        $pid = db('member')->where('id',$param['id'])->find();
        if (empty($pid['pid'])){
            db('member')->where('id',$param['id'])->update(['pid',$param['pid']]);
        }
    }
}